package cn.wolfcode.wolf2w.search.repository;

import cn.wolfcode.wolf2w.search.api.domain.UserInfoEs;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Highlight;
import org.springframework.data.elasticsearch.annotations.HighlightField;
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface UserInfoEsRepository extends ElasticsearchRepository<UserInfoEs, String>{
    /**
     * 按照 所在城市, 昵称, 个人简介 查询数据
     *
     * @param city
     * @param nickname
     * @param info
     * @param pageable
     * @return
     */
    @Highlight(
            fields = {
                    @HighlightField(name = "city"),
                    @HighlightField(name = "nickname"),
                    @HighlightField(name = "info")
            },
            parameters = @HighlightParameters(
                    preTags = "<span style='color:red'>",
                    postTags = "</span>",
                    requireFieldMatch = false,
                    fragmentSize = 800000,
                    numberOfFragments = 0
            )
    )
    SearchPage<UserInfoEs> queryByCityOrNicknameOrInfo(String city, String nickname, String info, Pageable pageable);
}
